import type { DepartData, DepartItem , Image, OrderDetail, OrderListData, OrderParams, OrderPreData, OrderPreParams, OrderQuery, PayParams} from "@/types/consult"
import { request } from "@/utils/request"

// 1. 封装获取科室接口
export const getDepartmentApi = () => {
  return request.get<null, DepartData[]>('/dep/all')
}

// 2. 封装上传图片接口
export const uploadImgApi = (filePath: string)=>{
  return request.upload<null, Image>('/upload', {
    name: 'file',
    filePath
  })
}

// 3. 创建订单接口
export const preOrderApi = (params: OrderPreParams) => {
  return request.get<null, OrderPreData>('/patient/consult/order/pre', {
    params
  })
}

// 4. 生成待支付订单
export const createOrderApi = (data:OrderParams) => {
  return request.post<null, {id:string}>('/patient/consult/order', data)
}


 //三方支付（暂时只支持支付宝支付）
 
export const orderPayApi = (data: PayParams) => {
  return request.post<null, {payUrl:string}>('/patient/consult/pay', data)
}

/**
 * 问诊订单详情
 */
export const orderDetailApi = (orderId: string) => {
  return request.get<null, OrderDetail>('/patient/consult/order/detail', { params: { orderId } })
}

/**
 * 医生问诊列表
 */
export const orderListApi = (data:OrderQuery) => {
  return request.get<null, OrderListData>('/patient/consult/order/list', { params: data })
}


